package com.liu.demo.utils;

import com.liu.demo.exception.REnum;
import com.liu.demo.vo.R;

/**
 * 对R对象进行简化
 */
public class RUtils {

    public static R success(Object object){
        R res = new R();
        res.setCode(200);
        res.setMsg("success");
        res.setData(object);

        return res;
    }

    public static R success(Integer code,String msg){
        R res = new R();
        res.setCode(code);
        res.setMsg(msg);
        res.setData(null);

        return res;
    }
    public static R success(){
        return success(null);
    }

    public static R error(Integer code,String msg){
        R res = new R();
        res.setCode(code);
        res.setMsg(msg);
        res.setData(null);

        return res;
    }

    public static R error(REnum rEnum){
        return error(rEnum.getCode(),rEnum.getMsg());
    }
}
